﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
 <div class="scrollbox" style="max-width:488px">
<ul data-bind="foreach: availableFacilities" id="vmFacilities">
    <li  data-bind="css: { 'odd': ($index() % 2 != 0) }">
        <input type="checkbox" data-bind="attr: { value: Facilities_ID }, checked: $root.selectedFacilities" name="Facilities"><span data-bind="text: Facilities" ></span>
    </li>
</ul>
 </div>
<script type="text/javascript">
    $(document).ready(function() {
     var selected = [""];
        <% if(Model.ToString()!=""){
         %>
            selected =[<%=Model.ToString()%>];
         <%}  %>
    System.Data.Facilities = function() {
            var self = this;

            self.availableFacilities = ko.observableArray([]);
            self.selectedFacilities = ko.observableArray(selected);
            //load
            (function() {
            $.getJSON(BASE_URL + "Listings/Ajax/GetFacilities", function(result) {
                self.availableFacilities(result.Data);

                });
            })();
        }
        //
        var vmFacilities = new System.Data.Facilities();
        ko.applyBindings(vmFacilities, $("#vmFacilities")[0]);
       
    });
</script>